//
// Created by 11510 on 2025/10/2.
//

#include "HistoryCommand.h"


xclib_client::HistoryCommand::HistoryCommand(CommandContext ctx) : ICommand("history", ctx) {}

std::optional<std::future<int>> xclib_client::HistoryCommand::run(const std::vector<std::string> &args, bool wait) {
    (void) args;
    (void) wait;
    if (!ctx.history)
        return std::nullopt;
    size_t idx = 0;
    for (auto &h: *ctx.history)
        std::cout << ++idx << "  " << h << '\n';
    return std::nullopt;
}

std::string xclib_client::HistoryCommand::shortHelp() const { return "show command history"; }

std::string xclib_client::HistoryCommand::longHelp() const { return "history\n    print command history"; }
